package com.ruibang.glass.produce.controller.lh;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.constant.Constants;
import com.ruibang.glass.produce.domain.req.CommonTrendChartReq;
import com.ruibang.glass.produce.domain.req.MoistureDetecitonReq;
import com.ruibang.glass.produce.domain.resp.MoistureDetecitonTrendChart;
import com.ruibang.glass.produce.service.MoistureDetecitonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruibang.glass.produce.entity.MoistureDeteciton;

import javax.servlet.http.HttpServletResponse;


/**
 * <p>
 * 生产-理化-原料水分 前端控制器
 * </p>
 *
 * @author songJinKang
 * @since 2024-03-12
 */
@RestController

@RequestMapping("/api/glass/produce/lh/moistureDeteciton")
@Api(value = "生产-理化-原料水分控制器", tags = {"生产-理化-原料水分接口"})
public class MoistureDetecitonController {

    @Autowired
    private MoistureDetecitonService moistureDetecitonService;

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取生产-理化-原料水分", notes = "获取生产-理化-原料水分")
    public ResultBody getById(@PathVariable(value = "id") String id) {
        return ResultBody.success(moistureDetecitonService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增生产-理化-原料水分", notes = "新增生产-理化-原料水分")
    public ResultBody save(@RequestBody MoistureDeteciton moistureDeteciton) {
        moistureDetecitonService.saveInfo(moistureDeteciton);
        return ResultBody.success();
    }

    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "通过ID删除生产-理化-原料水分", notes = "通过ID删除生产-理化-原料水分")
    public ResultBody delete(@PathVariable(value = "id") String id) {
        moistureDetecitonService.delete(id);
        return ResultBody.success();
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改生产-理化-原料水分", notes = "修改生产-理化-原料水分")
    public ResultBody edit(@RequestBody MoistureDeteciton moistureDeteciton) {
        moistureDetecitonService.edit(moistureDeteciton);
        return ResultBody.success();
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询生产-理化-原料水分", notes = "分页列表查询生产-理化-原料水分")
    public ResultBody<IPage<MoistureDeteciton>> pageQuery(@RequestBody MoistureDetecitonReq moistureDetecitonReq) {
        return ResultBody.success(moistureDetecitonService.pageQuery(moistureDetecitonReq));
    }

    @PostMapping("/trendChart")
    @ApiOperation(value = "趋势图")
    public ResultBody<MoistureDetecitonTrendChart> trendChart(@RequestBody CommonTrendChartReq trendChartReq) {
        return ResultBody.success(moistureDetecitonService.trendChart(trendChartReq));
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出")
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 4, target = FrequencyControl.Target.IP)
    public void export(@RequestBody MoistureDetecitonReq moistureDetecitonReq, HttpServletResponse response) {
        moistureDetecitonService.export(moistureDetecitonReq, response);
    }
}
